<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

			if (!function_exists('exitJs')) {
				function exitJs($script) {   
	                header("Content-type: text/javascript; charset=utf-8");
					header("Expires: Thu, 01 Jan 1990 00:00:00 GMT");
					exit($script);
	             }
			}
			
			if (!function_exists('exitHTML')) {
				function exitHTML($str, $js_tag = false) {   
	                header("Content-type: text/html; charset=utf-8");
					header("Expires: Thu, 01 Jan 1990 00:00:00 GMT");
					
					if ($js_tag)
					{
						$str = '<script type="text/javascript">'.$str.'</script>';
					}
					
					exit($str);
	             }
			}
			
			if (!function_exists('formError')) {
				function formError($strError = '', $isAjax = false, $iFrame = false) {   
	                $idDiv = $isAjax ? 'result_ajax' : 'result';
					$strScript = '$("#'.$idDiv.'").html(\'<div class="error form_error">%s</div>\');';
					
					if ($iFrame)
					{
						exit('<script type="text/javascript">parent.' . sprintf($strScript, $strError) . '</script>');
					}
					
	                exitJs(sprintf($strScript, $strError));
	             }
			}
			
			if (!function_exists('formOK')) {
				function formOK($str = '', $isAjax = false) {   
	                $idDiv = $isAjax ? 'result_ajax' : 'result';
					$strDiv = '$("#'.$idDiv.'").html(\'<div class="ok form_ok">%s</div>\');';
	                exitJs(sprintf($strDiv, $str));
	             }
			}
			
			if (!function_exists('formRedirect')) {
				function formRedirect($urlRedir = '') {   
	                $strScript = 'window.location.href = "%s";';
	                exitJs(sprintf($strScript, $urlRedir));
	             }
			}
?>